// 排除反向引用

let room = {
    number: 23
};

let meetup = {
    title: "Conference",
    occupiedBy: [{name: "John"}, {name: "Alice"}],
    place: room
};

// 循环引用
room.occupiedBy = meetup;

meetup.self = meetup;

alert(JSON.stringify(meetup, function replacer(key, value) {
    if (key == 'occupiedBy' && value == meetup) {
        return undefined;
    } else if (key == 'self') {
        return undefined;
    } else {
        return value;
    }
}));

